//
//  VisitorView.swift
//  JGWB
//
//  Created by 付建国 on 2016/10/9.
//  Copyright © 2016年 sher. All rights reserved.
//

import UIKit

class VisitorView: UIView {
    // MARK:- 提供快速通过xib创建的类方法
    class func visitorView() -> VisitorView {
    
        return Bundle.main.loadNibNamed("VisitorView", owner: nil, options: nil)?.first as! VisitorView
        
    }
    
    // MARK:- 控件属性
    @IBOutlet weak var rotationView: UIImageView!
    
    @IBOutlet weak var iconView: UIImageView!

    @IBOutlet weak var tipLabel: UILabel!
    
    @IBOutlet weak var registorBtn: UIButton!
    
    @IBOutlet weak var loginBtn: UIButton!
    
    
    // MARK:- 自定义函数
    func setupVisitorViewInfo(_ iconName : String, title : String){
        iconView.image = UIImage.init(named: iconName)
        tipLabel.text = title
        rotationView.isHidden = true
    }
    
    func addRotationAnim() {
        //1.创建动画
        let rotationAnim = CABasicAnimation.init(keyPath: "transform.rotation.z")
        //2.设置动画属性
        rotationAnim.fromValue = 0
        rotationAnim.toValue = M_PI
        
        rotationAnim.repeatCount = MAXFLOAT
        rotationAnim.duration = 6
        //核心动画如果不设置这个属性，在离开页面或进入后台动画会结束
        rotationAnim.isRemovedOnCompletion = false
        
        //3.添加动画到layer
        rotationView.layer.add(rotationAnim, forKey: nil)

        
    }
}
